#pragma once

#ifdef _WIN32
#include <Windows.h>
#undef min

inline void gettimeofday(struct timeval* tp, void* tzp) {
	FILETIME ft;
	ULARGE_INTEGER ull;
	GetSystemTimeAsFileTime(&ft);

	ull.LowPart = ft.dwLowDateTime;
	ull.HighPart = ft.dwHighDateTime;

	ull.QuadPart -= 116444736000000000LL; // Convert from Windows epoch to Unix epoch  

	tp->tv_sec = (long)(ull.QuadPart / 10000000LL);
	tp->tv_usec = (long)((ull.QuadPart % 10000000LL) / 10LL);
}

inline void sleep(int sec)
{
	Sleep(sec * 1000);
}

inline void usleep(int ws)
{
	Sleep(ws / 1000);
}

#include <time.h>
#else
#include <sys/time.h>
#endif

